﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <title>注册信息-企业用户-【赛码网】</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,target-densitydpi=device-dpi,minimum-scale=1,maximum-scale=1,user-scalable=1" />
    <link rel="Shortcut Icon" href="/images/acm.ico">
    <link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/css/jquery.cxdialog.css" />
    <link rel="stylesheet" type="text/css" href="/css/all-exam.css" />
    <link rel="stylesheet" type="text/css" href="/css/user/login2.css" />
    <style type="text/css">
        .login-error {
            padding-left: 63px;
            color: #ff0000;
        }

        .b {
            position: absolute;
            left: -12px;
            top: 12px;
            color: #ff8a00;
        }

        .stra-b {
            left: 2px;
        }

        #examregist {
            display: inline-block;
            line-height: 24px;
        }
    </style>
</head>
<body>
    <div class="main-box">
        <!--head-->
        <div class="container-fluid container-fluid-t">
            <div class="head">
                <div class="head-bar public">
                    <div class="logo">
                        <a href="../job/index.html"><img src="../../images/logo.png" /></a>
                        <p><span>考试平台</span></p>
                    </div>
                </div>
            </div>
            <!--head  end-->
            <div class="userCnt row">
                <div class="loginCnt">
                    <h1>注册信息</h1>
                    <div class="login-box">
                        <ul>
                            <li>
                                <!-- <span class="regisit-span">+86</span> -->
                                <span class="leftNw"><b class="b">*</b>公司全称：</span>
                                <input type="text" name="name" class="login-text input regisit-phone vadana" placeholder="请输入企业全称" />
                            </li>
                            <li>
                                <!-- <span class="regisit-span">+86</span> -->
                                <span class="leftNw"><b class="b">*</b>公司简称：</span>
                                <input maxlength="9" type="text" name="shortName" class="login-text input regisit-phone vadana" placeholder="请输入企业简称" />
                            </li>
                            <li>
                                <!-- <span class="regisit-span">+86</span> -->
                                <span class="newsN leftNw "><b class="b stra-b" style="left: 10px;">*</b>姓名：</span>
                                <input type="text" name="contactName" class="login-text input regisit-phone vadana" placeholder="请输入您的姓名" />
                            </li>
                            <li>
                                <!-- <span class="regisit-span">+86</span> -->
                                <span class="newsS leftNw"><b class="b stra-b">*</b>手机号：</span>
                                <input type="text" name="contactPhone" class="login-text input regisit-phone vadana" value="" placeholder="请输入手机号" />
                            </li>
                            <li>
                                <!-- <span class="regisit-span">+86</span> -->
                                <span class="newsE leftNw"><b class="b stra-b">*</b>E_mail：</span>
                                <input type="text" name="contactEmail" class="login-text input regisit-phone vadana" placeholder="请输入E-mail" />
                            </li>
                            <!-- <li>
                                <input type="text" class="login-text input regisit-send-input" placeholder="验证码"/>
                                <a href="javascript:void(0)"  class="regisit-send">获取验证短信</a>
                            </li> -->
                            <li>
                                <span class="leftNw">任职职位：</span>
                                <input type="text" name="contactPosition" class="login-text input input-p" placeholder="请输入任职职位" />
                            </li>
                            <li>
                                <input type="button" value="提交" onclick="javascript:void(0)" id="examregist" class="login-btn btn" />
                            </li>
                        </ul>
                    </div>
                    <div class="login-f">
                        已有账号，<a href="/enterprise/login">马上登录 >></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--footer-->
    <script src="/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="https://cdn.acmcoder.com/static/1.0.1/js/jquery.cookie.js"></script>
    <script src="/js/footer-exam.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="/js/jquery.cxdialog.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/all.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/user/regist.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
			window.alert = function(mess){
				$.cxDialog({
					title: '提示',
					info: '<div style="padding:20px;text-align:center;">' + mess + '</div>',
					lockScroll: true,
					background: '#000',
					width:400,
					okText:"我知道了",
					ok: function(){
					}
				});
				return false;
			}
			/*修改输入框内容*/
			$(function(){
				var arry=['公司全称','公司简称','姓名','手机号','E-mail','任职职位'];
				   if ($(document).width()<=450) {
				   	    for (var i = 0; i < arry.length; i++) {
				   	    	 $('.login-text').eq(i).attr('placeholder',arry[i]);
				   	    }

				   } else{
                        return;
				   }

			});
			$("#examregist").click(function() {
				var $name = $("input[name='name']"),
						$shortName = $("input[name='shortName']"),
						$contactName = $("input[name='contactName']"),
						$contactPhone = $("input[name='contactPhone']"),
						$contactEmail = $("input[name='contactEmail']"),
						$contactPosition = $("input[name='contactPosition']");
				if ($name.val() == null || $.trim($name.val()) == '') {
					alert("请输入企业全称");
				}else if(getByteLen($.trim($name.val()))>100){
					setErrMsg($name,"企业全称过长，请输入100个字符以内的全称");
				} else if ($shortName.val() == null || $.trim($shortName.val()) == '') {
					alert("请输入企业简称");
				} else if(getByteLen($.trim($shortName.val()))>16){
					setErrMsg($shortName,"企业简称过长，请输入16个字符以内的简称");
				} else if ($contactName.val() == null || $.trim($contactName.val()) == '') {
					alert("请输入联系人姓名");
				} else if(getByteLen($.trim($contactName.val()))>10){
					setErrMsg($contactName,"联系人姓名过长，请输入10字以内的姓名");
				} else if ($contactPhone.val() == null || $.trim($contactPhone.val()) == '') {
					alert("请输入联系人手机");
				} else if (!checkMobile( $.trim( $contactPhone.val() ) ) ){
					setErrMsg($contactPhone,"请输入正确的手机号");
				} else if($contactEmail.val()==null||$.trim($contactEmail.val())=='') {
					alert("请输入联系人邮箱");
				} else if(!checkEmail( $.trim( $contactEmail.val() ) )) {
					setErrMsg($contactEmail,"请输入正确的邮箱");
				}else{
					//随机获取头像
					var photos = {};
					photos[0] = '/images/defphoto/photoOne.png';
					photos[1] = '/images/defphoto/photoTwo.png';
					photos[2] = '/images/defphoto/peopleThree.png';
					photos[3] = '/images/defphoto/peopleFour.png';
					photos[4] = '/images/defphoto/peopleFive.png';
					photos[5] = '/images/defphoto/peopleSix.png';
					photos[6] = '/images/defphoto/peopleSeven.png';
					photos[7] = '/images/defphoto/peopleEight.png';
					photos[8] = '/images/defphoto/peopleNine.png';
					photos[9] = '/images/defphoto/peopleTen.png';
					var random = Math.floor(Math.random()*10);
					$.post('/b/addEntInfo',{
						name: $.trim($name.val()),
						shortName: $.trim($shortName.val()),
						contactName: $.trim($contactName.val()),
						contactPhone: $.trim($contactPhone.val()),
						contactPhoto:photos[random],
						contactEmail: $.trim($contactEmail.val()),
						contactPosition: $.trim($contactPosition.val())
					},function(json){
						if(json.success){
							var map  = json.datas ;
							if (map != null && map != undefined)
							{
								var did = map.did;
								var aid = map.aid;
//														$.ajax({
//									type:'post',
//									data:{'did':did,'creater':aid},
//									url:'http://kaosys.acmcoder.com/api/createDemoExaminationPaper',
//									xhrFields: {withCredentials: true},
//									success:function(data){console.log(data);}
//								});
								$.ajax({
									type:'post',
									data:{'did':did,'creater':aid},
									url:'https://kaosys.acmcoder.com/api/createDemoExaminationPaper',
									xhrFields: {withCredentials: true},
									success:function(data){location.href='/b/';},
									error:function(){ location.href='/b/';}
								});
							}
							else
							{
								window.location.href='/b/';
							}
						}else{
							alert("添加公司信息失败！");
						}
					},'json');
				}

			});
			$(document).keydown(function(event){
				if(event.keyCode == 13)
					$('#examregist').click();
			});
			//移除样式
			$('li input').keydown(function(){
				$(this).parent('li').removeClass('regisit-error');
				$(this).siblings('p').remove();
			});
			var setErrMsg = function(_id, msg){
				if(_id.parent().find('p').length == 0)
					_id.parent().addClass('regisit-error').append('<p class="login-error "><i></i>' + msg + '</p>');
			}
			var checkMobile = function(str) {
				var re = /^1\d{10}$/;
				if (re.test(str))
					return true;
				else
					return false;
			}
			var checkEmail = function(str) {
				var re = /^(\w-*\.*)+(\w-?)+(\.\w{2,})+$/;
				if (re.test(str))
					return true;
				else
					return false;
			}
			/*姓名限制弹框*/
			$('input[name="contactName"]').blur(function(){
				var v= $.trim($(this).val());
				var thats= $(this)

				if(v.length>=11){
					$(this).attr('disabled','disabled')
					$.cxDialog({
						title:'提示',
						info:'<div style="padding-bottom:20px;padding-top:20px;text-align:center;">姓名最多只能输入10个字符</div>',
						lockScroll: true,
						closeBtn: true,
						background: '#000',
						okText:'我知道了',
						ok:function(){
							$('input[name="contactName"]').val(v);
							thats.removeAttr('disabled')
						}
					})
				}
			});
			function getByteLen(val) {
				var len = 0;
				for (var i = 0; i < val.length; i++) {
					var a = val.charAt(i);
					if (a.match(/[^\x00-\xff]/ig) != null) {
						len += 2;
					}
					else {
						len += 1;
					}
				}
				return len;
			}

    </script>
</body>
</html>

